\subsection{Блок-схемы}

\begin{figure}[ht]  
\begin{subfigure}[t]{0.5\textwidth}
\centering
\begin{tikzpicture}[node distance = 1cm, auto]
        \node [cloud]                                                 (start)  {Начало};
        \node [block, below of = start]                               (i1)     {$i:=1$};
        \node [decision, below of = i1,      node distance = 2.5cm]   (iley)   {$i\leq 9?$};
        \node [block, below of = iley,       node distance = 2.5cm]   (f_i)    {$n:=f(i)$};
        \node [block, below of = f_i,        node distance = 1.5cm]   (j1)     {$j:=1$};
        \node [print_block, below of = j1]                            (out0)   {$m_0,i,0$};
        \node [decision, below of = out0,    node distance = 2.5cm]   (jlen)   {$j\leq n?$};
        \node [print_block, below of = jlen, node distance = 2.5cm]   (out1)   {$m_j,i,j$};
        \node [print_block, below of = out1]                          (out2)   {$j,i,m_j$};
        \node [block, below of = out2,       node distance = 1.5cm]   (j++)    {$j:=j+1$};
        
        \path [line] (start) -- (i1);
        \path [line] (i1) -- node (in1) {} (iley);      
        \path [line] (iley) -- node (yes1) {Да} (f_i);
        \path [line] (f_i) -- (j1);
        \path [line] (j1) -- (out0);
        \path [line] (out0) -- node (in2) {} (jlen);
        \path [line] (jlen) -- node (yes2) {Да} (out1);
        \path [line] (out1) -- (out2);
        \path [line] (out2) -- (j++);
%        \path [line] (j++) -- ++(-1.5,0) -- ++(0,6.75) -- (in2);
        \path [line] (j++) -- ++(-1.5,0) |- (in2);
        
        \node [cloud, right of = yes1, node distance = 2cm]    (finish) {Конец};
        \path [line] (iley) -| node [near start] {Нет} (finish);
        
        \node [block, right of = yes2, node distance = 2cm]    (i++) {$i:=i+1$};
        \path [line] (jlen) -| node [near start] {Нет} (i++);
        \path [line] (i++) -- ++(1.5,0) |- (in1);
        
  \end{tikzpicture}
  \caption{Основная программа}
  \label{bsb_1}
\end{subfigure}
%~
\begin{subfigure}[t]{0.4\textwidth}
\centering
\begin{tikzpicture}[node distance = 1cm, auto]
        \node [cloud]                                   (start)   {$f(i)$};
        \node [block, below of = start]                 (j0)      {$j:=0$};
        \node [block, below of = j0]                    (y)       {$y:=\lfloor\frac{x}{2}\rfloor$};
        \node [block, below of = y, node distance = 1.5cm](m)       {$m[j]:=i-j$};
        \node [block, below of = m]                     (j++)     {$j:=j+1$};
        \node [decision, below of = j++]                (jmty)    {$j>y$};
        \node [block, below of = jmty, node distance = 2.5cm](f)      {$f:=j-1$};
        \node [cloud, below of = f]                     (fin)     {Конец};
        
        \path [line] (start) -- (j0);
        \path [line] (j0) -- (y);
        \path [line] (y) -- node (in1) {} (m);
        \path [line] (m) -- (j++);
        \path [line] (j++) -- (jmty);
        \path [line] (jmty) -- node [near start] {Нет} ++(-2,0) |- (in1);
        
        
        \path [line] (jmty) -- node {Да} (f);
        \path [line] (f) -- (fin);
        
  \end{tikzpicture}
  \caption{Функция f(x)}
  \label{bsb_2}
\end{subfigure}

\caption{Блок-схемы к бонусному заданию}
  \label{bsb}
\end{figure}
